﻿#include "ImageTrans.h"
#include <QDir>

ImageTrans::ImageTrans(TransferProxy *proxy)
    :FileTransfer(proxy) {

}

void ImageTrans::send(const QVariant &var, const QVariant &extra) {
    QString path = var.toString();
    path = path.remove("file:///");
    sendFile(path);
    QString displayInfo = QString("<img src = \"file:///%1\" width=\"%2\" height=\"%3\"><br>").arg(path).arg(400).arg(400);
    mTransproxy->updataComInfo(true, displayInfo);
}

QString ImageTrans::transferPrefix() {
    return prefix();
}

QString ImageTrans::prefix()
{
    return "Image";
}

QString ImageTrans::getSaveDir() {
    QString saveDir = QDir::currentPath() + "/Temp/Image/";
    //路径不存在就创建
    CheckPathIsExist(saveDir);
    return saveDir;
}

void ImageTrans::saveOverFunc() {
    QString path = getSaveDir() + mSaveFileName;
    QString displayInfo = QString("<img src = \"file:///%1\" width=\"%2\" height=\"%3\"><br>").arg(path).arg(400).arg(400);
    mTransproxy->updataComInfo(false, displayInfo);
}
